package com.ymttest.database.sqlwapper.shenqisettlement;

import java.util.HashMap;
import java.util.List;

import com.ymt.core.tool.Logger;
import com.ymt.database.SqlManager;
import com.ymttest.database.model.shenqisettlement.ShengpaySharingConverge;

public class ShengpaySharingConvergeWrapper {
	
	SqlManager manager;

    public ShengpaySharingConvergeWrapper() {
        manager = new SqlManager("shenqisettlement");
    }
    
    @SuppressWarnings("unchecked")
	public List<ShengpaySharingConverge> selectByOrderId(Long orderId) {
    	
    	List<ShengpaySharingConverge> result = manager
                .getSelectResults(
                        "com.ymttest.database.mapping.shenqisettlement.ShengpaySharingConvergeMapper.selectByOrderId",
                        orderId);
        manager.commit();
        
		if (result.size() == 0) {
			Logger.comment("shengpay_sharing_converge没有数据");
			
			return null;
		}
		
		return result;
    }
    
	@SuppressWarnings("unchecked")
	public ShengpaySharingConverge selectByOrderIdAndUserIdAndBizType(
			Long orderId, Long userId, Integer bizType) {

		ShengpaySharingConverge shengpaySharingConverge = null;

		HashMap<String, Object> map = new HashMap<>();

		map.put("order_id", orderId);
		map.put("sharing_user_id", userId);
		map.put("sharing_biz_type", bizType);

		List<ShengpaySharingConverge> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.shenqisettlement.ShengpaySharingConvergeMapper.selectByOrderIdAndUserIdAndBizType",
						map);
		manager.commit();

		if (result.size() == 0) {
			Logger.comment("shengpay_sharing_converge没有数据");
		} else
			shengpaySharingConverge = result.get(0);

		return shengpaySharingConverge;
	}
    
    public static void main(String[] args) {
    	ShengpaySharingConvergeWrapper wrapper = new ShengpaySharingConvergeWrapper();
    	Logger.debug(wrapper.selectByOrderIdAndUserIdAndBizType(13405118699L, 501395811L, 2).getAmount());
    }
}
